<?php

namespace Admin\Form;
use Zend\Form\Form;
use Zend\Form\Element;
use Base\Form\ProvidesEventsForm;
use User\Options\RegistrationOptionsInterface;
use Zend\Stdlib\Hydrator\ClassMethods as ClassMethodsHydrator;

class UpdateUserForm extends ProvidesEventsForm
{
    public function __construct($name , RegistrationOptionsInterface $options)
    {
        $this->setRegistrationOptions($options);
        parent::__construct();

        /*$this->setAttribute('method', 'post')
            ->setAttribute('novalidate');
        //$this->remove('userId');*/
        //$this->setHydrator(new ClassMethodsHydrator(false));

        $this->add(array(
            'type' => 'Admin\Form\UpdateUserFieldset',
            'options' => array(
                'use_as_base_fieldset' => true,
            ),
        ));

        $submitElement = new Element\Button('submit');
        $submitElement
            ->setLabel('Submit')
            ->setAttributes(array(
                'type'  => 'submit',
                'class' => 'btn btn-primary',
                'icon'    => '<i class="fa fa-angle-right"></i> ',
            ));

        $this->add($submitElement, array(
            'priority' => -100,
        ));

        /*
        $this->add(array(
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf',
            'options' => array(
                'csrf_options' => array(
                    'timeout' => 600
                )
            )
        ));*/

        $this->get('submit')->setLabel('Update User');
        $this->getEventManager()->trigger('init', $this);
    }
    /**
     * Set Registration Options
     *
     * @param RegistrationOptionsInterface $registrationOptions
     * @return Register
     */
    public function setRegistrationOptions(RegistrationOptionsInterface $registrationOptions)
    {
        $this->registrationOptions = $registrationOptions;
        return $this;
    }

    /**
     * Get Registration Options
     *
     * @return RegistrationOptionsInterface
     */
    public function getRegistrationOptions()
    {
        return $this->registrationOptions;
    }
} 